<?php
$this->pageTitle = 'Zoznam typov osôb';
?>
<div class="listing">
	<h3>Zoznam typov osôb</h3>
	<table class="list">
		<thead>
			<tr>
				<th class="identifier"><?php echo $this->Paginator->sort('id', 'ID'); ?></th>
				<th><?php echo $this->Paginator->sort('title', 'Názov typu'); ?></th>
				<th class="col50"><?php echo $this->Paginator->sort('top_of_group', 'Vedúci skupiny'); ?></th>
				<th class="col50"><?php echo $this->Paginator->sort('top_of_structure', 'TOP'); ?></th>
				<th class="col50" colspan="3"><?php echo 'Provízia (%)'; ?></th>
				<th class="action"><?php echo 'Akcie'; ?></th>
			</tr>
		</thead>
		<tbody>
			<?php
			foreach ($personTypes as $personType):
			?>
			<tr>
				<td class="number">
					<?php echo $personType['PersonType']['id']; ?>
				</td>
				<td>
					<?php echo htmlspecialchars($personType['PersonType']['title']); ?>
				</td>
				<td>
					<?php echo ($personType['PersonType']['top_of_group'] ? 'áno' : 'nie'); ?>
				</td>
				<td>
					<?php echo ($personType['PersonType']['top_of_structure'] ? 'áno' : 'nie'); ?>
				</td>
				<td class="number">
					<?php 
						$commission = $personType['PersonType']['commission_0_tipsters'];
						if (in_array($commission, array(0, 100))) {
							echo '-';
						} else {
							echo $commission;
						}
					?>
				</td>
				<td class="number">
					<?php 
						$commission = $personType['PersonType']['commission_1_tipster'];
						if (in_array($commission, array(0, 100))) {
							echo '-';
						} else {
							echo $commission;
						}
					?>
				</td>
				<td class="number">
					<?php 
						$commission = $personType['PersonType']['commission_2_tipsters'];
						if (in_array($commission, array(0, 100))) {
							echo '-';
						} else {
							echo $commission;
						}
					?>
				</td>
				<td>
					<?php
						if (isset($userPermissions['person_type']['view'])) {
							echo $this->Html->link(__('View', true), array('action' => 'view', $personType['PersonType']['id']), array('class' => 'show'));
						}
					?>
					<?php
						if (isset($userPermissions['person_type']['edit'])) {
							echo $this->Html->link(__('Uprav', true), array('action' => 'edit', $personType['PersonType']['id']), array('class' => 'edit'));
						}
					?>
					<?php
						if (isset($userPermissions['person_type']['delete'])) {
							echo $this->Html->link(__('Delete', true), array('action' => 'delete', $personType['PersonType']['id']), array('class' => 'delete'), __('Ste si istý, že chcete odstrániť záznam?', true));
						}
					?>
				</td>
			</tr>
			<?php endforeach; ?>
		</tbody>
	</table>

	<?php if ($this->Paginator->hasPage(2)): ?>
		<div class="pager">
			<?php echo $this->Paginator->prev('<< '.__('predchádzajúca', true), array(), null, array('class'=>'disabled')); ?>
			<?php echo $this->Paginator->numbers(); ?>
			<?php echo $this->Paginator->next(__('ďalšia', true).' >>', array(), null, array('class' => 'disabled')); ?>
		</div>
	<?php endif; ?>
</div>